//
//  GTListitem.swift
//  headline-Swfit
//
//  Created by 大土豆 on 2019/8/23.
//  Copyright © 2019 Mac. All rights reserved.
//

import Foundation

class GTListitem :NSObject,NSSecureCoding{
    static var supportsSecureCoding: Bool = true
    
    //属性必须要加上@objc，YYModel才能识别，否则无法识别
    @objc  var category  = ""
    @objc  var picUrl = ""
    @objc  var uniqueKey = ""
    @objc  var title = ""
    @objc  var date = ""
    @objc  var authorName = ""
    @objc var articleUrl = ""
    
    override init() {
        super.init()
    }
    
    required init?(coder aDecoder: NSCoder) {
        self.category = aDecoder.decodeObject(forKey: "category") as! String
        self.category = aDecoder.decodeObject(forKey: "picUrl") as! String
        self.category = aDecoder.decodeObject(forKey: "uniqueKey") as! String
        self.category = aDecoder.decodeObject(forKey: "title") as! String
        self.category = aDecoder.decodeObject(forKey: "date") as! String
        self.category = aDecoder.decodeObject(forKey: "authorName") as! String
        self.category = aDecoder.decodeObject(forKey: "articleUrl") as! String
    }
    
    func encode(with aCoder: NSCoder) {
        aCoder.encode(self.category, forKey: "category")
        aCoder.encode(self.picUrl, forKey: "picUrl")
        aCoder.encode(self.uniqueKey, forKey: "uniqueKey")
        aCoder.encode(self.title, forKey: "title")
        aCoder.encode(self.date, forKey: "date")
        aCoder.encode(self.authorName, forKey: "authorName")
        aCoder.encode(self.articleUrl, forKey: "articleUrl")
    }
    
    //YYModel必须手写这些对应关系，如果值有变动的话，对应方法也必须加上@objc，不然YYmodel识别不到
    @objc class func modelCustomPropertyMapper() -> NSDictionary {
        return ["category":"category",
        "picUrl":"thumbnail_pic_s",
        "uniqueKey":"uniquekey",
        "title":"title",
        "date":"date",
        "authorName":"author_name",
        "articleUrl":"url"]
    }
    
}


